package com.zlp.pay.mapper;

import com.zlp.pay.entity.PaymentTransactionEntity;
import org.apache.ibatis.annotations.*;


public interface PaymentTransactionMapper {


	@Options(useGeneratedKeys = true, keyProperty = "id")
	@Insert("INSERT INTO `payment_transaction` VALUES (null, #{paymentId}, #{payAmount}, 0, #{userId}, null,  #{orderId},1, null, now(), now(),null);")
	int insertPaymentTransaction(PaymentTransactionEntity paymentTransactionEntity);

	@Select("SELECT id AS ID ,pay_amount AS payAmount,payment_status AS paymentStatus,user_id AS userId, order_Id AS orderId , created_time as createdTime ,partypay_id as partyPayId , payment_id as paymentId FROM payment_transaction WHERE ID=#{id};")
	PaymentTransactionEntity selectById(Long id);

	@Select("SELECT ID AS ID ,pay_Amount AS payAmount,payment_Status AS paymentStatus,user_ID AS userId, order_Id AS orderId , created_Time as createdTime ,partypay_Id as partyPayId , payment_Id as paymentId  FROM payment_transaction WHERE PAYMENT_ID=#{paymentId};")
	PaymentTransactionEntity selectByPaymentId(String paymentId);

	@Update("update payment_transaction SET PAYMENT_STATUS=#{paymentStatus}   WHERE PAYMENT_ID=#{paymentId}; ")
	int updatePaymentStatus(@Param("paymentStatus") String paymentStatus, @Param("paymentId") String paymentId,
								   @Param("paymentChannel") String paymentChannel);
	
}
